/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Negocio;

import DAO.ResourcesDAO;
import Entidades.ResourceEnt;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import com.jcraft.jsch.UserInfo;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.ConnectException;
import java.net.SocketException;
import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;

/**
 *
 * @author usuario
 */
public class SubirFTPNeg {
        
    ResourcesDAO resource;
    
    public int uploadToFTP(File file, String tema) throws SQLException{
    
            int subido = 0;
            boolean response = false;
            FTPClient ftp = new FTPClient();
            FileInputStream inputStream = null;

            FileInputStream fileInputStream;      
            resource = new ResourcesDAO();
            String path = "";
            String user = "";
            String miContraseña = "";
            String host = "";
            List<ResourceEnt> lstReso;
            lstReso = resource.busquedaResources();

            for (ResourceEnt res : lstReso) {

            if(res.getClave().trim().equals("USUARIO_FTP")){
                 user = res.getValor();
             }

            if(res.getClave().trim().equals("CLAVE_FTP")){
                 miContraseña = res.getValor();
             }

            if(res.getClave().trim().equals("DIRECCION_FTP")){
                 host = res.getValor();
             }
   
            
            if(res.getClave().trim().equals("DIRECTORIO_FTP")){
                 path = res.getValor();
             }
        }
        return 0;

    }
    
    public boolean deleteFromFTP(String rutaArchivo){
        
        boolean eliminado = false;
        File file = new File(rutaArchivo);
        eliminado = file.delete();
        return eliminado;
    }
}
